package com.fau.wm.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.wm.action.PublicAction;
import com.fau.wm.entity.MedicalAdmin;
import com.fau.wm.entity.MedicalStorageDetail;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc  入库统计Action
 * @author liy
 * @datetime 2014年8月18日,上午10:28:41
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class StatisticsStorageAction extends PublicAction implements ModelDriven<MedicalStorageDetail> {

	private static final long serialVersionUID = 7115820449913302040L;
	
	private MedicalStorageDetail storageDetail = new MedicalStorageDetail();
	
	/**
	 * @desc 分页查询详细入库单
	 * @return null
	 * @author liy
	 * @datetime 2014年8月19日,下午3:41:18
	 */
	@Action(value = "statistics_storage_page")
	public String statisticsStoragePage(){
		this.map = ActionContext.getContext().getParameters();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		storageDetail.setHospitalId(admin.getEnterpriseId());
		this.pageBean = this.baseAllService.getStatisticsManagerService().findStorageDetailByPage(storageDetail, this.map);
		this.map.clear();
		map.put("total", this.pageBean.getTotalRow());
		map.put("data", this.pageBean.getResult());
		HttpServletResponse response = ServletActionContext.getResponse();
		formatJSON(response, this.map);
		return null;
	}
	
	/**
	 * @desc 进入入库统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年8月19日,上午11:27:49
	 */
	@Action(value = "statistics_storage", results = {@Result(location = "statistics_storage.jsp")})
	public String statisticsStorage() {
		return SUCCESS;
	}

	public MedicalStorageDetail getStorageDetail() {
		return storageDetail;
	}

	public void setStorageDetail(MedicalStorageDetail storageDetail) {
		this.storageDetail = storageDetail;
	}

	@Override
	public MedicalStorageDetail getModel() {
		return storageDetail;
	}

}
